/*
 * (C) APUE
 * print the mask signals name
 */
#include "apue.h"
#include <errno.h>

void pr_mask(const char *str)
{
	sigset_t sigset;
	int errno_save;

	errno_save = errno;	/* we can be called by signal handlers */

	/* get the signal mask set */
	if (sigprocmask(0, NULL, &sigset) < 0)
		err_quit("sigprocmask error");

	printf("%s", str);

	if (sigismember(&sigset, SIGINT)) printf("SIGINT ");
	if (sigismember(&sigset, SIGQUIT)) printf("SIGQUIT ");
	if (sigismember(&sigset, SIGUSR1)) printf("SIGUSR1 ");
	if (sigismember(&sigset, SIGALRM)) printf("SIGALRM ");

	/* if you want to recognize more mask signals, go here */
	/* ... */

	printf("\n");
	errno = errno_save;
}
